<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
  <head>
    <title>首页</title>
    <style>
    	#main.2{
    		color:red;
    		align:center;
    	}
    </style>
  </head>
  
  <body>
  	<%
  		
  		
  	 %>
    <div id="main">
    
    	<div id="1">
    	<c:choose>
    		<c:when test="${user==null}">
    			<a href="<%=request.getContextPath() %>/LoginUI">登陆</a>
    			<a href="<%=request.getContextPath() %>/RegisterUI">注册</a>
    		</c:when>
    		<c:otherwise>
    			欢迎您${user }的登陆
    			<br/><a href="<%=request.getContextPath() %>/LoginOutUI">退出登陆</a>
    		</c:otherwise>
    	</c:choose>	
    	</div>
    	<div id="2">
    		电话通讯录管理系统
    	</div>
    	<div id="3">
    		<table>
    		<c:if test="${user!=null}">
    			<tr>
    				<td>
    				姓名
    				</td>
    				<td row="3">
    				手机号码
    				</td>
    				<td>
    					<a href="<%=request.getContextPath() %>/AddPhoneUI?id=${id }">增加记录</a>
    				</td>
    				
    				<td>
    				<a href="<%=request.getContextPath() %>/FindPhoneUI?id=${id }">查找</a>	
    				</td>				
    			</tr>
    			
    			<c:forEach var="str" items="${map}">
    			<tr>
    				<c:if test="${str.value['page'] == page}">
    				<td>
    				${str.value['username'] }
    				</td>
    				<td row="3">
    				${str.value['phonenumber'] }
    				</td>
    				
    				<td>
    					<a href="<%=request.getContextPath() %>/UpdatePhoneUI?userid=${str.value['userid']}" >修改</a>
    				</td>
    				<td>
    					<a href="<%=request.getContextPath() %>/DeletePhoneUI?userid=${str.value['userid']}">删除</a>
    				</td>
    				</c:if>	
    			</tr>
    			</c:forEach>	
    		</c:if>	
    		</table>
    		<c:if test="${user !=null}">
       			<a href="<%=request.getContextPath() %>/ListPageDesServlet?page=${page }">上一页</a>
    				<c:forEach var="str" items="${list}">
    					<a href="<%=request.getContextPath() %>/ListPageServlet?page=${str }">${str }</a>
    				</c:forEach>
    			<a href="<%=request.getContextPath() %>/ListPageAddServlet?page=${page }">下一页</a>
    		</c:if>
    	</div>
    </div>
  </body>
</html>
